'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 抽奖
 * @author sundbcn@gmail.com (sun debing)
 */

var modelUtil = require('../util/modelUtil');
var mongoConnector = require('../libs/mongodb/mongoConnector');
/* jshint unused:false */
var luckySchema = require('../schemas/luckySchema');
var Lucky = mongoConnector().model('Lucky');
var moment = require('moment');

/**
 * 根据role_id获取用户抽奖
 * @return {[type]} [description]
 */
module.exports.getByRoleId = function (role_id, cb) {
    modelUtil.getByRoleId(Lucky, role_id, function (err, luck_model) {
        if (!!err) {
            console.error(err);
            return cb(err);
        }

        cb(null, luck_model);
    });
};

/**
 * 5点刷新
 */
module.exports.onFiveRefresh = function (self, cb) {
    self.reset();
    cb();
};
